-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Convert "method has return statement; needs result type" to new error format with MissingReturnTypeWithReturnStatement #3094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… format with MissingReturnTypeWithReturnStatement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Added" instead of "Add")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
@allanrenucci: could you review this PR please? |
val msg = hl"$method has a return statement; it needs a result type" | ||
val explanation = | ||
hl"""|If a method contains a ${"return"} statement, it must have a return | ||
|type explicitly given to it. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...it must have an explicit result type. For example:
hl"""|If a method contains a ${"return"} statement, it must have a return | ||
|type explicitly given to it. For example: | ||
| | ||
|${"def bad() = { return \"fail\" }"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would give a valid example instead:
def good: Int /* explicit result type */ = {
return 1
}
|
||
val MissingReturnTypeWithReturnStatement(method) :: Nil = messages | ||
|
||
assertEquals(method.name.toString, "bad") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name.show
""".stripMargin | ||
}.expect { (ictx, messages) => | ||
implicit val ctx: Context = ictx | ||
val defn = ictx.definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
I've corrected the PR as per your review comments. |
@@ -963,13 +963,9 @@ class ErrorMessagesTests extends ErrorMessagesTest { | |||
|} | |||
""".stripMargin | |||
}.expect { (ictx, messages) => | |||
implicit val ctx: Context = ictx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defn
was not used but I think you still need the implicit ctx
. It is passed implicitly to the method show
assertMessageCount(1, messages) | ||
|
||
val MissingReturnTypeWithReturnStatement(method) :: Nil = messages | ||
|
||
assertEquals(method.name.toString, "bad") | ||
assertEquals(method.show, "bad") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be method.name.show
Sorry, should have run the tests :P Should be all good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheReturningVoid Thank you for your contribution 🎉
LGTM. Just waiting for the CI to go green
Convert "method has return statement; needs result type" to new error format with MissingReturnTypeWithReturnStatement